<template>
	<view class="account">
		<view class="list" v-if="accountList.length > 0">
			<view class="item" v-for="(item, index) in accountList" :key="index">
				<view class="icon">
					<image :src="item.logo_image" mode=""></image>
				</view>
				<view class="info">
					<view class="name">{{item.account_name}} 【{{item.name}}】</view>
					<view class="no">{{item.account_no}}</view>
				</view>
				<view class="del">
					<view class="del-btn" @tap="del(item)">删除</view>
				</view>
			</view>
		</view>
		
		<view class="no-data" v-else>你还没有添加收款帐号</view>
		
		<navigator url="add-account" class="fixed-bottom-btn">添加提现帐号</navigator>
	</view>
</template>

<script>
	import Request from '../../common/request.js';
	
	export default {
		data() {
			return {
				accountList: []
			};
		},
		onShow() {
			this.getDetail();
		},
		methods: {
			getDetail: function(){
				var that = this;
				Request.send({
					url: 'funds/account',
					sCallback: function(res) {
						that.accountList = res.data
					}
				})
			},
			//删除
			del: function(item, index){
				var that = this;
				uni.showModal({
					title:'提示',
					content: '确认删除该提现帐号吗？',
					success(e) {
						if(e.confirm == 1) {
							Request.send({
								url: 'funds/delAccount',
								data: {
									id: item.id
								},
								sCallback: function(res) {
									that.accountList.splice(index, 1);
									uni.showToast({
										title:res.msg
									})
								}
							})
						}
					}
				})
			}
		}
	}
</script>

<style>
	.account{
		font-size: 28upx;
		margin-bottom: 90upx;
	}
	
	.list{
		background: #fff;
		margin-top: 10upx;
	}
	
	.list .item{
		padding: 20upx;
		border-bottom: 1upx solid #eee;
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	
	.list .item .info{
		flex: 1;
		padding: 0 20upx;
	}
	
	.list .del{
		display: flex;
		
	}
	
	.list .del-btn{
		border: 1upx solid #E60012;
		color: #E60012;
		padding: 6upx 20upx;
		border-radius: 10upx;
		font-size: 24upx;
	}
	
	.icon image{
		width: 100upx;
		height: 100upx;
	}
</style>
